<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <!--{include file='comm/header.tpl'}-->
    <title>文章分类列表</title>
</head>
<body>

<!--{include file='comm/naviBanner.tpl'}-->

<div class="container">

    <!--{include file='comm/menu.tpl'}-->

    <div class="comm_crub">
        <span class="now_crub">文章分类列表</span>
    </div>

    <div class="comm_content">

        <table id="flex" style="display:none"></table>

    </div>

</div>

<script type="text/javascript">
    $("#flex").flexigrid({
        url:"/invokingAjax-backend/content/article.ajax?operFlg=1",
        dataType: "json",
        colModel : [
            {display: "操作", width : 200, align: "center"},
            {display: "分类号", name : "category_id", width : 100, sortable : true},
            {display: "分类标题", width : 260},
            {display: "分类别名", width : 100},
            {display: "分类类型", width : 100},
            {display: "描述", width : 360},
            {display: "使用标志", width : 70, align: "center"}
        ],
        buttons : [
            {name: "添加", bclass: "add", onpress : "article.add"},
            {separator: true},
            {name: "删除", bclass: "delete", onpress : "article.deleteArticle"}
        ],
        sortname: "category_id",
        sortorder: "desc",
        usepager: true,
        rp: 10,
        useRp: true,
        showTableToggleBtn: true,
        onSubmit: function() {
            var dt = $('#search_form').serializeArray();
            $("#flex").flexOptions({params: dt});
            return true;
        }
    });

    var article = {

        delete_str: "",

        //查询
        search: function () {
            var dt = $('#search_form').serializeArray();
            $("#flex").flexOptions({params: dt}).flexReload();
        },

        //添加
        add: function() {
            E.open("/quanliadmin/app/content/article.pscript?operFlg=2");
        },

        //编辑
        edit: function (category_id) {
            E.open("/quanliadmin/app/content/article.pscript?operFlg=3&category_id=" + category_id);
        },

        //重新加载页面内容
        load: function() {
            $("#flex").flexReload();
        },

        deleteArticle: function() {
            this.delete_str = "";
            $.each($("#flex").find("tr"), function(k, v) {
                if ($(v).hasClass("trSelected")) {
                    article.delete_str += "_" + $(v).attr("id").replace("row", "");
                }
            });

            if (this.delete_str == "")
                E.alert("请选择删除文章分类");
            else
                E.confirm("<b>该操作同时会删除分类下的所有文章</b><br /><br />您确认要删除选中的文章分类吗？", "article.deleteConfirm");
        },

        deleteConfirm: function() {
            this.delete_str = this.delete_str.substr(1);
            $.ajax({
                type: "POST",
                url: "/invokingAjax-backend/content/article.ajax?operFlg=6&delete_str=" + article.delete_str,
                dataType: "JSON",
                success: function( result_obj ) {
                    if (result_obj.code == 200) {
                        E.alert(result_obj.message, 2, "article.load");
                    } else {
                        E.alert(result_obj.message);
                    }
                }
            });
        }

    };
</script>

</body>
</html>